import Cookies from 'js-cookie'

const TokenKey = 'Weather-Token'
const kaptchaOwner = 'kaptchaOwner'

export function getToken () {
  return Cookies.get(TokenKey)
}

export function setToken (token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken () {
  return Cookies.remove(TokenKey)
}

export function getKaptcha () {
  return Cookies.get(kaptchaOwner)
}
export function setKaptcha (kaptcha) {
  const seconds = 10
  const expires = new Date(new Date() * 1 + seconds * 6000) // 60秒失效
  return Cookies.set(kaptchaOwner, kaptcha, { expires: expires })
}
